<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CompanyDeliveryOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('company_delivery_order', ['engine' => 'InnoDB', 'comment' => '公司配送单', 'signed' => false]);
        $table->addColumn('company_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '公司id', 'signed' => false])
              ->addColumn('store_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '门店id', 'signed' => false])
              ->addColumn('driver_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '司机id', 'signed' => false])
              ->addColumn('is_load', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '是否装车:1未装车,2已装车', 'signed' => false])
              ->addColumn('delivery_no', 'string', ['limit' => 50, 'default' => '', 'comment' => '配送单号', 'signed' => false])
              ->addColumn('company_order_ids', 'string', ['limit' => 1000, 'default' => '', 'comment' => '公司订单id集', 'signed' => false])
              ->addColumn('delivery_status', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '配送状态:1待签收,2已签收,3已拒收,4已取消', 'signed' => false])
              ->addColumn('order_num','integer',['limit'=>10,'default'=>0,'comment'=>'订单数量','signed'=>false])
              ->addColumn('delivery_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '配送金额', 'signed' => false])
              ->addColumn('return_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '退货金额', 'signed' => false])
              ->addColumn('exchange_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '换货金额', 'signed' => false])
              ->addColumn('sign_img', 'string', ['limit' => 1000, 'default' => '', 'comment' => '签收凭证', 'signed' => false])
              ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '创建时间', 'signed' => false])
              ->addColumn('update_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '更新时间', 'signed' => false])
              ->addColumn('delete_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '删除时间', 'signed' => false])
              ->addIndex(['company_id', 'store_id', 'driver_id'])
              ->create();
    }
}
